/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package index;

/**
 *
 * @author Lu
 */
public class StatsWordElement {
    private String element;
    private String document;
    private String word;
    private int counter;
    private float tf;
    private float idf;

    public StatsWordElement(String element, String document, String word){
        this.element = element;
        this.document = document;
        this.word = word;
        counter = 1;
    }

    public StatsWordElement(String element, String document, String word, int counter, float tf, float idf){
        this.element = element;
        this.document = document;
        this.word = word;
        this.counter = counter;
        this.tf = tf;
        this.idf = idf;
    }

    public String toString(){
        return document+"  "+element+" "+word+"  tf="+tf+" idf="+idf+" count="+counter;
    }

    public void addOne(){
        counter++;
    }

    public void computeTfIdf(int wordsTotal){
        tf = counter / (float)wordsTotal;
        idf = (float) Math.log(wordsTotal / (float)counter);
    }

    public String getElement() {
        return element;
    }

    public String getDocument() {
        return document;
    }

    public String getWord() {
        return word;
    }

    public int getCounter() {
        return counter;
    }

    public float getTf() {
        return tf;
    }

    public float getIdf() {
        return idf;
    }


}
